<#include "/java_copyright.include">
<#assign className = table.className>   
<#assign tableName = table.sqlName>   
<#assign classNameLower = className?uncap_first>
package ${basepackage}.service;

import java.sql.PreparedStatement;
import java.sql.ResultSet;

<#include "/java_imports.include">

public class ${className}Service {
	private ${className}Dao ${classNameLower}Dao = new ${className}Dao();
	
	public boolean insert(Connection conn,${className} ${classNameLower}){
		try{
			conn.setAutoCommit(false);
			${classNameLower}Dao.insert(conn,${classNameLower});
			conn.commit();
		} catch(Exception e){
			conn.rollback();
			throw new ServiceException(e);
		}
	}

	public boolean update(Connection conn,${className} ${classNameLower}){
		try{
			conn.setAutoCommit(false);
			${classNameLower}Dao.update(conn,${classNameLower});
			conn.commit();
		} catch(Exception e){
			conn.rollback();
			throw new ServiceException(e);
		}
	}

	public boolean delete(Connection conn,${className} ${classNameLower}){
		try{
			conn.setAutoCommit(false);
			${classNameLower}Dao.delete(conn,${classNameLower});
			conn.commit();
		} catch(Exception e){
			conn.rollback();
			throw new ServiceException(e);
		}
	}
	
	public ${className} get(Connection conn,Integer id){
		return ${classNameLower}Dao.get(conn,id);
	}
	
	public List<${className}> list(Connection conn){
		return ${classNameLower}Dao.list(conn);
	}
	
}
